var ocpvideopopout = {
  onLoad: function() {
    // initialization code
    this.initialized = true;
    this.strings = document.getElementById("ocpvideopopout-strings");	
	
	try {
	   var firefoxnav = document.getElementById("nav-bar");
	   var curSet = firefoxnav.currentSet;
	   if (curSet.indexOf("ocpvideopopout-toolbar-button") == -1)
	   {
		 var set;
		 // Place the button before the urlbar
		 if (curSet.indexOf("urlbar-container") != -1)
		   set = curSet.replace(/urlbar-container/, "ocpvideopopout-toolbar-button,urlbar-container");
		 else  // at the end
		   set = curSet + ",ocpvideopopout-toolbar-button";
		 firefoxnav.setAttribute("currentset", set);
		 firefoxnav.currentSet = set;
		 document.persist("nav-bar", "currentset");
		 // If you don't do the following call, funny things happen
		 try {
		   BrowserToolboxCustomizeDone(true);
		 }
		 catch (e) { }
	   }
	 }
	catch(e) { }	
  },

  onMenuItemCommand: function(e) {
	ocpvideopopout.onToolbarButtonCommand(e);
  },

  onToolbarButtonCommand: function(e) {
 	var myScript = top.window.content.document.createElement("script");	
	myScript.src="resource://ocpvideopopout/OCPVideoPOPOUT.js";
	top.window.content.document.body.appendChild(myScript);
  }
  

};

window.addEventListener("load", ocpvideopopout.onLoad, false);


 